package com.lc202310;

/**
 * Description:
 *
 * @Create 2023/10/27 19:30
 * @Version 1.0
 */
public class Solution36 {
    public boolean isValidSudoku(char[][] board) {
        int[][] row = new int[9][9];
        int[][] column = new int[9][9];
        int[][][] box = new int[3][3][9];
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                char c = board[i][j];
                if (c != '.') {
                    int x = c - '1';
                    row[i][x]++;
                    column[j][x]++;
                    box[i / 3][j / 3][x]++;
                    if (row[i][x] > 1 || column[j][x] > 1 || box[i / 3][j / 3][x] > 1) {
                        return false;
                    }
                }

            }
        }
        return true;
    }
}
